<ui:composition template="/WEB-INF/template/padrao.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="title">Configuração de Usuários</ui:define>
	<ui:define name="corpo">

		<h:form id="form">
		
			<p:dataTable id="radioDT" value="#{userLogadoMB.lUser}" var="u"	border="1" cellpadding="10" selectionMode="single" rowKey="#{u.username}">
				
				<p:ajax listener="#{configuraUserMB.onRowSelectUser}" event="rowSelect"></p:ajax>
				
				<p:column selectionMode="single" style="width:16px;text-align:center" />
				
				<p:column headerText="Usuários Logados no Sistema">
					<h:outputText value="#{u.username}" />
				</p:column>
				
				<f:facet name="footer">
         	  	<p:commandButton process="radioDT" update=":form:userDetail" icon="ui-icon-search" value="View" oncomplete="PF('userVar').show()" />
       			</f:facet>
			</p:dataTable>
			

			<p:dialog header="Administração: #{configuraUserMB.selectedUser.username}" widgetVar="userVar" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
				<p:outputPanel id="userDetail" style="text-align:center;">
					<p:panelGrid columns="2" rendered="#{not empty configuraUserMB.selectedUser}" columnClasses="label,value">

						<h:outputText value="Username: " />
						<h:outputText value="#{configuraUserMB.selectedUser.username}" />

						<h:commandLink value="Efetuar logoff" actionListener="#{configuraUserMB.logoutSelectedUser}"/>

						<h:commandLink value="Gerenciar permissões" action="/pages/restricted/users/gerenciaPermissao.xhtml"/>

					</p:panelGrid>
				</p:outputPanel>
			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>